<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Register</title>
</head>
    <body>
    <?php
		session_start();
		
		if (isset($_SESSION['username'])){
			header("Location: index.php");
		}
		
	    if (isset($_POST['register'])){
			$user = $_POST['username'];
			$pass = $_POST['password'];
			$enc_pass = md5($pass);
			$money = $_POST['money'];
			
			$database = "tractors";
			$host = "localhost";
			$db_user = "root";

			$link = mysqli_connect($host, $db_user, "", $database) or die("Could not connect to $database" . mysql_error());
			$query = "INSERT INTO client(username, password, money) VALUES('$user', '$enc_pass', '$money')";
			mysqli_query($link, $query) or die("Could not create user" . mysqli_error($link));
			mysqli_close($link);
			
			header("Location: index.php");
		}
	?>
	
	<form method="post">
		<label for "username">Username: </label><input type="text" name="username"/>
		<label for "password">Password: </label><input type="password" name="password"/>
		<label for "repeat_pass">Repeat Password: </label><input type="password" name="repeat_password"/>
		<label for "money">Money: </label><input type="text" name="money"/>
		<p><input type="submit" value="register" name="register"/></p>
		<p>or <a href="login.php">Login</a></p>
	</form>
    </body>
</html>